@extends('layout.wechat_frame')

@section('main')

    <header class="mui-bar mui-bar-nav">
        <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
        <h1 class="mui-title">询价报价</h1>
    </header>

    <div class="mui-content">
        <ul class="mui-table-view mui-table-view-striped mui-table-view-condensed">

            @if (count($enquiries) > 0)
                @foreach ($enquiries as $k => $enquiry)

                    <?php
                    $replied = $enquiry->replies()->where('supplier_id', auth()->user()->id)->exists();
                    ?>

                    <li class="mui-table-view-cell">
                        <div class="mui-table">
                            <div class="mui-table-cell mui-col-xs-10">
                                <h5 class="mui-ellipsis">{{ $enquiry->title }}</h5>
                                <h5><span class="ips-span-first">{{ $enquiry->goods->name }}</span>&nbsp;&nbsp;<span>采购数量：{{ strval((float)$enquiry->quantity) }}吨</span></h5>
                                <h5><span>报价截止：{{ $enquiry->stop_at }}</span>&nbsp;&nbsp;
                                        @if($enquiry->stop_at > $datetime and $enquiry->start_at < $datetime)
                                        <span class="ips-text-red">询价中</span>
                                        @elseif ($enquiry->start_at > $datetime)
                                            <span>未开始</span>
                                        @elseif ($enquiry->stop_at < $datetime)
                                            <span class="ips-text-blue">已截止</span>
                                        @endif
                              </h5>
                            </div>
                        </div>
                        <div>

                            @if ($enquiry->stop_at > $datetime and !$replied)
                                {!! \App\Services\IPSWechatHelper::showButton(['type'=>'link', 'title'=>'报价单报价', 'href'=>route('enquiryQuote.eqDetail', ['enquiry' => $enquiry->id]), 'css'=>'ips-row-btn mui-btn-blue', 'text'=>'报价']) !!}
                            @else
                                {!! \App\Services\IPSWechatHelper::showButton(['type'=>'link', 'title'=>'查看报价单', 'href'=>route('enquiryQuote.eqListDetail', ['enquiry' => $enquiry->id]), 'css'=>'ips-row-btn mui-btn-red', 'text'=>'详情']) !!}
                            @endif

                        </div>
                    </li>

                @endforeach
            @else
                <li class="mui-table-view-cell">
                    <h5 class="mui-ellipsis">没有报价单</h5>
                </li>
            @endif
        </ul>
    </div>


@section('js')

@stop